﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace AppMain
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            Application.Run(new StartWindow());
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            LogData log = new LogData();
            
            MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
            log.Write(string.Format("\nException Message: \n{0}", (e.ExceptionObject as Exception).Message));
            log.Write(string.Format("Exception StackTrace: \n{0}", (e.ExceptionObject as Exception).StackTrace));
            log.Write(string.Format("Exception TargetSite: \n{0}", (e.ExceptionObject as Exception).TargetSite));
            log.Write(string.Format("Is Terminating: {0}\n", (e.IsTerminating)));
        }
    }
}
